Add explicit casts from void* in prep for C++ migration.
authorrobertl <robertl>
Wed, 21 Apr 2010 05:47:50 +0000 (05:47 +0000)
committerrobertl <robertl>
Wed, 21 Apr 2010 05:47:50 +0000 (05:47 +0000)
20 files changed:
avltree.c
cet.c
cetus.c
csv_util.c
filter_vecs.c
garmin_fs.c
gbser_posix.c
inifile.c
main.c
mkshort.c
nmea.c
pdbfile.c
route.c
session.c
trackfilter.c
unicsv.c
util.c
vecs.c
vmem.c
xmltag.c

index d6e7fb25e9aa0ac4cc8f079ef1725e84134cf94d..08c6c6e87d7a3a2f38df0b9eb231f2d00c75f2f0 100644 (file)
--- a/avltree.c
+++ b/avltree.c
@@ -67,7 +67,7 @@ avltree_init(const int options, const char *module)
        if ((module == NULL) || (*module == '\0'))
                fatal(MYNAME ": 'avltree_init' should be called with a valid module name!\n");
 
-       tree = xcalloc(1, sizeof(*tree));
+       tree = (avltree_t*) xcalloc(1, sizeof(*tree));
        tree->options = options;
        tree->module = module;
 
@@ -445,7 +445,7 @@ avltree_insert_node(avltree_t *tree, avlnode_t **root, const char *key, const vo
        avlnode_t *node = (*root);
 
        if (node == NULL) {
-               (*root) = node = xcalloc(1, sizeof(*node));
+               (*root) = node = (avlnode_t*) xcalloc(1, sizeof(*node));
                if (tree->options & AVLTREE_STATIC_KEYS)
                        node->key = key;
                else
@@ -643,7 +643,7 @@ avltree_delete_node(avltree_t *tree, const char *key, avlnode_t **root, int *cha
 static avlnode_t *
 avltree_dupe_node(const avltree_t *tree, const avlnode_t *node)
 {
-       avlnode_t *res = xcalloc(1, sizeof(*res));
+       avlnode_t *res = (avlnode_t*) xcalloc(1, sizeof(*res));
        
        if (tree->options & AVLTREE_STATIC_KEYS)
                res->key = node->key;
diff --git a/cet.c b/cet.c
index e4586249f96967ecb0c8731e13734e37282452d7..e88c6b316b441c6f9bbc22a8c40fda4aac92c339 100644 (file)
--- a/cet.c
+++ b/cet.c
@@ -356,7 +356,7 @@ cet_str_utf8_to_any(const char *src, const cet_cs_vec_t *vec)
        if (vec->ucs4_count == 0) return xstrdup(src); /* UTF-8 -> UTF-8 */
        
        len = strlen(c);
-       res = dest = xmalloc(len + 1);  /* target will become smaller or equal length */
+       res = dest = (char *) xmalloc(len + 1); /* target will become smaller or equal length */
        
        cend = c + len;
 
@@ -395,7 +395,7 @@ cet_str_any_to_utf8(const char *src, const cet_cs_vec_t *vec)
            len += cet_ucs4_to_utf8(NULL, 6, value);
        }
 
-       result = cout = xmalloc(len + 1);
+       result = cout = (char *) xmalloc(len + 1);
        cin = (char *)src;
 
        while (*cin != '\0')            
@@ -428,7 +428,7 @@ cet_str_uni_to_utf8(const short *src, const int length)
        while (i-- > 0)
            len += cet_ucs4_to_utf8(NULL, 6, le_read16(cin++));
        
-       res = cout = xmalloc(len + 1);
+       res = cout = (char *) xmalloc(len + 1);
        cin = (unsigned short *)src;
        i = length;
 
@@ -456,7 +456,7 @@ cet_str_any_to_uni(const char *src, const cet_cs_vec_t *vec, int *length)
        else utf8 = cet_str_any_to_utf8(src, vec);
 
        len = cet_utf8_strlen(utf8);
-       res = sout = xcalloc(2, len + 1);
+       res = sout = (short int *) xcalloc(2, len + 1);
        
        if (len) {
                char *cin = utf8;
diff --git a/cetus.c b/cetus.c
index bb1597151329ef0053e011970a8b17a6b4ab5b6d..764ce29f659166d9809e56182c3644ccb7ecc940 100644 (file)
--- a/cetus.c
+++ b/cetus.c
@@ -420,7 +420,7 @@ cetus_writewpt(const waypoint *wpt)
        char *desc_geo;
        char *desc;
 
-       rec = xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1);
+       rec = (struct cetus_wpt_s*) xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1);
 
        if (wpt->creation_time && (NULL != (tm = gmtime(&wpt->creation_time)))){
                rec->min = tm->tm_min;
@@ -557,8 +557,8 @@ static
 int 
 compare(const void *a, const void *b)
 {
-       const struct hdr *wa = a;
-       const struct hdr *wb = b;
+       const struct hdr *wa = (const struct hdr*) a;
+       const struct hdr *wb = (const struct hdr*) b;
 
        return strcmp(wa->wpt->shortname, wb->wpt->shortname);
 }
index 9a33bfe0854c3f3f75386740cd3e056b31ab3a9a..d68bb9986cae9224232dc3a0072822be44061d5a 100644 (file)
@@ -355,7 +355,7 @@ csv_lineparse(const char *stringstart, const char *delimited_by,
     }
     
     /* allocate enough space for this data field */
-    tmp = xcalloc((p - sp) + 1, sizeof(char));
+    tmp = (char *) xcalloc((p - sp) + 1, sizeof(char));
 
     strncpy(tmp, sp, (p - sp));
     tmp[p - sp] = '\0'; 
@@ -630,7 +630,7 @@ dec_to_human( char *buff, const char *format, const char *dirs, double val )
     dblvals[2] = 60*(dblvals[1]-intvals[1]);
     intvals[2] = (int)dblvals[2];
     
-    subformat = xmalloc( strlen(format)+2);
+    subformat = (char*) xmalloc( strlen(format)+2);
     formatptr = format;
     
     buff[0] = '\0';
@@ -697,14 +697,14 @@ xcsv_file_init(void)
     /* ofield is alloced to allow pointing back at ifields
      * where applicable.
      */
-    xcsv_file.ofield = xcalloc(sizeof(queue), 1);
+    xcsv_file.ofield = (queue*) xcalloc(sizeof(queue), 1);
     QUEUE_INIT(xcsv_file.ofield);
     /*
      * Provide a sane default for CSV _files_.
      */
     xcsv_file.type = ff_type_file;
 
-    xcsv_file.mkshort_handle = mkshort_new_handle();
+    xcsv_file.mkshort_handle = (struct short_handle_*) mkshort_new_handle();
     xcsv_file.gps_datum = GPS_DATUM_WGS84;
 }
 
@@ -715,7 +715,7 @@ xcsv_file_init(void)
 void
 xcsv_ifield_add(char *key, char *val, char *pfc)
 {
-    field_map_t *fmp = xcalloc(sizeof(*fmp), 1);
+    field_map_t *fmp = (field_map_t *) xcalloc(sizeof(*fmp), 1);
     struct xt_mapping *xm = in_word_set(key, strlen(key));
     
     fmp->key = key;
@@ -734,7 +734,7 @@ xcsv_ifield_add(char *key, char *val, char *pfc)
 void
 xcsv_ofield_add(char *key, char *val, char *pfc, int options)
 {
-    field_map_t *fmp = xcalloc(sizeof(*fmp), 1);
+    field_map_t *fmp = (field_map_t *) xcalloc(sizeof(*fmp), 1);
     struct xt_mapping *xm = in_word_set(key, strlen(key));
     
     fmp->key = key;
@@ -754,7 +754,7 @@ xcsv_ofield_add(char *key, char *val, char *pfc, int options)
 void
 xcsv_prologue_add(char *prologue)
 {
-    ogue_t* ogp = xcalloc(sizeof(*ogp), 1);
+    ogue_t* ogp = (ogue_t*) xcalloc(sizeof(*ogp), 1);
 
     ogp->val = prologue;
     ENQUEUE_TAIL(&xcsv_file.prologue, &ogp->Q);
@@ -768,7 +768,7 @@ xcsv_prologue_add(char *prologue)
 void
 xcsv_epilogue_add(char *epilogue)
 {
-    ogue_t * ogp = xcalloc(sizeof(*ogp), 1);
+    ogue_t * ogp = (ogue_t*) xcalloc(sizeof(*ogp), 1);
 
     ogp->val = epilogue;
     ENQUEUE_TAIL(&xcsv_file.epilogue, &ogp->Q);
@@ -840,7 +840,7 @@ addhms( const char *s, const char *format )
        char * ampm = NULL;
        int ac;
        
-       ampm = xmalloc( strlen(s) );
+       ampm = (char*) xmalloc( strlen(s) );
        ac = sscanf(s, format, &hour, &min, &sec, &ampm);
        /* If no time format in arg string, assume AM */
        if (ac < 4) {
@@ -1196,7 +1196,7 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp,
        wpt->sat = atoi(s);
        break;
     case XT_GPS_FIX:
-       wpt->fix = atoi(s)-1;
+       wpt->fix = (fix_type)(atoi(s)-(fix_type)1);
        if ( wpt->fix < fix_2d) {
        if (!case_ignore_strcmp(s, "none"))
                wpt->fix = fix_none;
index 249698346d7045881928bb7db5903d2e301ba739..b23d0bdb73efa74cfa6f30f9b96536e379bfba4a 100644 (file)
@@ -289,8 +289,8 @@ disp_filter_vec( const char *vecname )
 static signed int
 alpha (const void *a, const void *b)
 {
-        const fl_vecs_t *const ap = a;
-        const fl_vecs_t *const bp = b;
+        const fl_vecs_t *const ap = (const fl_vecs_t*) a;
+        const fl_vecs_t *const bp = (const fl_vecs_t*) b;
 
         return case_ignore_strcmp(ap->desc , bp->desc);
 }
index f980a51966e3a32772e8e6d35f3decf2d85f2d5a..04727478e05014ef5cc2725d7bf8361fd1616b46 100644 (file)
@@ -137,7 +137,7 @@ void garmin_fs_convert(void *fs)
 void 
 garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt)
 {
-       char *phone, *addr;
+       const char *phone, *addr;
        garmin_fs_t *gmsd = GMSD_FIND(waypt);
        
        if (gmsd == NULL) return;
@@ -421,4 +421,3 @@ garmin_fs_garmin_before_write(const waypoint *wpt, GPS_PWay way, const int proto
        GMSD_GETNSTR(cross_road, way->cross_road, sizeof(way->cross_road));
        GMSD_GETNSTR(addr, way->addr, sizeof(way->addr));
 }
-
index 665ffa338b1863415acd18e8f97eb503a5b03d6c..ecf1095ad8d9f10769d47af69f6dbd829e3b8ec6 100644 (file)
@@ -116,7 +116,7 @@ void *gbser_init(const char *port_name) {
 
        gbser__db(4, "gbser_init(\"%s\")\n", port_name);
 
-       h = xcalloc(sizeof *h, 1);
+       h = (gbser_handle*) xcalloc(sizeof *h, 1);
        h->magic = MYMAGIC;
        h->vmin = h->vtime = 0;
 
@@ -234,7 +234,7 @@ int gbser_set_port(void *handle, unsigned speed, unsigned bits, unsigned parity,
 unsigned gbser__read_buffer(void *handle, void **buf, unsigned *len) {
        gbser_handle *h = gbser__get_handle(handle);
     unsigned count = *len;
-    unsigned char *cp = *buf;
+    unsigned char *cp = (unsigned char *) *buf;
     if (count > h->inbuf_used) {
         count = h->inbuf_used;
     }
@@ -348,7 +348,7 @@ int gbser_flush(void *handle) {
  */
 int gbser_write(void *handle, const void *buf, unsigned len) {
        gbser_handle *h = gbser__get_handle(handle);
-    const char *bp = buf;
+    const char *bp = (const char *) buf;
     int rc;
     while (len > 0) {
         /*printf("write(%d, %p, %d)\n", h->fd, bp, len);*/
index d3b4fc923886f566ddaf7cbb88e74f070e772fb0..bc8ed914838c7d3666db388b3c7a6a12aff0d672 100644 (file)
--- a/inifile.c
+++ b/inifile.c
@@ -163,7 +163,7 @@ inifile_load_file(gbfile *fin, inifile_t *inifile, const char *myname)
                        if ((*cin == '\0') || (cend == NULL))
                                fatal("%s: invalid section header '%s' in '%s'.\n", myname, cin, gbinipathname);
                                
-                       sec = xcalloc(1, sizeof(*sec));
+                       sec = (inifile_section_t *) xcalloc(1, sizeof(*sec));
                        
                        sec->name = xstrdup(cin);
                        QUEUE_INIT(&sec->entries);
@@ -178,7 +178,7 @@ inifile_load_file(gbfile *fin, inifile_t *inifile, const char *myname)
                        if (sec == NULL)
                                fatal("%s: missing section header in '%s'.\n", myname,gbinipathname);
                        
-                       entry = xcalloc(1, sizeof(*entry));
+                       entry = (inifile_entry_t *) xcalloc(1, sizeof(*entry));
                        ENQUEUE_TAIL(&sec->entries, &entry->Q);
                        sec->ientries++;
                        
@@ -252,7 +252,7 @@ inifile_init(const char *filename, const char *myname)
        }
        else fin = gbfopen(filename, "rb", myname);
        
-       result = xcalloc(1, sizeof(*result));
+       result = (inifile_t *) xcalloc(1, sizeof(*result));
        QUEUE_INIT(&result->secs);
        inifile_load_file(fin, result, myname);
        
diff --git a/main.c b/main.c
index 778d6874322ac1b2de2a8ce31356a9b725d6dc64..8b70f7a0b16c855c4b3ed42322afc0e251587991 100644 (file)
--- a/main.c
+++ b/main.c
@@ -42,7 +42,7 @@ typedef struct arg_stack_s {
 static arg_stack_t
 *push_args(arg_stack_t *stack, const int argn, const int argc, char *argv[])
 {
-       arg_stack_t *res = xmalloc(sizeof(*res));
+       arg_stack_t *res = (arg_stack_t *) xmalloc(sizeof(*res));
        
        res->prev = stack;
        res->argn = argn;
@@ -98,13 +98,13 @@ load_args(const char *filename, int *argc, char **argv[])
        }
        gbfclose(fin);
        
-       argv2 = xmalloc(2 * sizeof(*argv2));
+       argv2 = (char **) xmalloc(2 * sizeof(*argv2));
        argv2[0] = xstrdup(*argv[0]);
        argc2 = 1;
        
        str = csv_lineparse(line, " ", "\"", 0);
        while (str != NULL) {
-               argv2 = xrealloc(argv2, (argc2 + 2) * sizeof(*argv2));
+               argv2 = (char **) xrealloc(argv2, (argc2 + 2) * sizeof(*argv2));
                argv2[argc2] = xstrdup(str);
                argc2++;
                str = csv_lineparse(NULL, " ", "\"", 0);
index 748fd5f9fc07f2f60abef022ca4e7c9b0a149c8a..33b1cb9d540a1401faac354a621e3509337c44f4 100644 (file)
--- a/mkshort.c
+++ b/mkshort.c
@@ -101,7 +101,7 @@ mkshort_new_handle()
 #endif
 {
        int i;
-       mkshort_handle *h = xxcalloc(sizeof *h, 1, file, line);
+       mkshort_handle *h = (mkshort_handle *) xxcalloc(sizeof *h, 1, file, line);
 
        for (i = 0; i < PRIME; i++)
                QUEUE_INIT(&h->namelist[i]);
@@ -138,7 +138,7 @@ void
 add_to_hashlist(mkshort_handle *h, char *name)
 {
        int hash = hash_string(name);
-       uniq_shortname *s = xcalloc(1, sizeof (uniq_shortname));
+       uniq_shortname *s = (uniq_shortname*) xcalloc(1, sizeof (uniq_shortname));
 
        s->orig_shortname = xstrdup(name);
        ENQUEUE_TAIL(&h->namelist[hash], &s->list);
@@ -159,7 +159,7 @@ mkshort_add_to_list(mkshort_handle *h, char *name)
                dl = sprintf(tbuf, ".%d", s->conflictctr);
 
                if (l + dl < h->target_len) {
-                       name = xrealloc(name, l + dl + 1);
+                       name = (char *) xrealloc(name, l + dl + 1);
                        strcat(name, tbuf);
                }
                else {
diff --git a/nmea.c b/nmea.c
index 43759c83d13a5ab57f121e2bcc89a56bcf592ce6..86f11e20ad42b04986801127ec857602e577d019 100644 (file)
--- a/nmea.c
+++ b/nmea.c
@@ -331,7 +331,7 @@ nmea_wr_init(const char *portname)
                }
        }
 
-       mkshort_handle = mkshort_new_handle();
+       mkshort_handle = (struct short_handle_*) mkshort_new_handle();
        setshort_length(mkshort_handle, atoi(snlenopt));
 
        if (opt_gisteq) {
@@ -1345,7 +1345,9 @@ nmea_wr_posn_deinit(void)
 
 ff_vecs_t nmea_vecs = {
        ff_type_file,
-       { ff_cap_read | ff_cap_write, ff_cap_read | ff_cap_write, ff_cap_none},
+       { (ff_cap)(ff_cap_read | ff_cap_write),
+          (ff_cap)(ff_cap_read | ff_cap_write), 
+          ff_cap_none},
        nmea_rd_init,   
        nmea_wr_init,   
        nmea_rd_deinit, 
index 2f9c1638ffff12a43c555ac68b16bc51cd52a05a..8c852d42e0a08833eb85b6941ee3beb081a88938 100644 (file)
--- a/pdbfile.c
+++ b/pdbfile.c
@@ -60,7 +60,7 @@ pdb_read_tail(gbfile *fin, gbuint32 *size)
        while ((count = gbfread(buff, 1, sizeof(buff), fin))) {
                
                if (!res) {
-                       res = xmalloc(count);
+                       res = (char *) xmalloc(count);
                        memcpy(res, buff, count);
                }
                else {
diff --git a/route.c b/route.c
index bfd378d3e9ad90b0f0444c3315593846bddff3ec..14dd4dee685f466acbbd4406595fd65ee02926fd 100644 (file)
--- a/route.c
+++ b/route.c
@@ -372,7 +372,7 @@ route_copy( int *dst_count, int *dst_wpt_count, queue **dst, queue *src ) {
        }
        
        if ( !*dst ) {
-               *dst = xcalloc( 1, sizeof( queue ));
+               *dst = (queue *)xcalloc( 1, sizeof( queue ));
                QUEUE_INIT( *dst );
                *dst_count = 0;
                *dst_wpt_count = 0;
@@ -529,7 +529,7 @@ tracks_to_routes(void)
 void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
 {
        waypoint first;
-       waypoint *this;
+       waypoint *thisw;
        waypoint *prev = &first;
        queue *elem, *tmp;
        int tkpt = 0;
@@ -538,7 +538,7 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
        int pts_cad = 0;
        double tot_cad = 0.0;
        char tkptname[100];
-       computed_trkdata *tdata = xcalloc(1, sizeof (computed_trkdata));
+       computed_trkdata *tdata = (computed_trkdata *)xcalloc(1, sizeof (computed_trkdata));
 
        if (trkdatap) {
                *trkdatap = tdata;
@@ -555,17 +555,17 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
                time_t timed;
                double tlat, tlon, plat, plon, dist;
 
-               this = (waypoint *)elem;
-               timed = this->creation_time - prev->creation_time;
+               thisw = (waypoint *)elem;
+               timed = thisw->creation_time - prev->creation_time;
 
                /* 
                 * gcdist and heading want radians, not degrees.
                 */
-               tlat = RAD(this->latitude);
-               tlon = RAD(this->longitude);
+               tlat = RAD(thisw->latitude);
+               tlon = RAD(thisw->longitude);
                plat = RAD(prev->latitude);
                plon = RAD(prev->longitude);
-               WAYPT_SET(this, course, heading_true_degrees(plat, plon,
+               WAYPT_SET(thisw, course, heading_true_degrees(plat, plon,
                        tlat, tlon));
                dist = radtometers(gcdist(plat, plon, tlat, tlon));
 
@@ -581,63 +581,63 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
                 * conditionally recompute speeds.
                 */
                if (timed && (dist > 1)) {
-                       if(!WAYPT_HAS(this, speed)) {
+                       if(!WAYPT_HAS(thisw, speed)) {
                                // Only recompute speed if the waypoint
                                // didn't already have a speed
-                               WAYPT_SET(this, speed, dist / labs(timed));
+                               WAYPT_SET(thisw, speed, dist / labs(timed));
                        }
-                       if (this->speed > tdata->max_spd) {
-                               tdata->max_spd = this->speed;
+                       if (thisw->speed > tdata->max_spd) {
+                               tdata->max_spd = thisw->speed;
                        }
-                       if (this->speed < tdata->min_spd) {
-                               tdata->min_spd = this->speed;
+                       if (thisw->speed < tdata->min_spd) {
+                               tdata->min_spd = thisw->speed;
                        }
                }
 
-               if ((this->altitude > 0) && (this->altitude < tdata->min_alt)) {
-                       tdata->min_alt = this->altitude;
+               if ((thisw->altitude > 0) && (thisw->altitude < tdata->min_alt)) {
+                       tdata->min_alt = thisw->altitude;
                }
-               if (this->altitude > tdata->max_alt) {
-                       tdata->max_alt = this->altitude;
+               if (thisw->altitude > tdata->max_alt) {
+                       tdata->max_alt = thisw->altitude;
                }
 
-               if (this->heartrate > 0) {
+               if (thisw->heartrate > 0) {
                        pts_hrt++;
-                       tot_hrt += (float) this->heartrate;
+                       tot_hrt += (float) thisw->heartrate;
                }
 
-               if ((this->heartrate > 0) && (this->heartrate < tdata->min_hrt)) {
-                       tdata->min_hrt = (int) this->heartrate;
+               if ((thisw->heartrate > 0) && (thisw->heartrate < tdata->min_hrt)) {
+                       tdata->min_hrt = (int) thisw->heartrate;
                }
 
-               if ((this->heartrate > 0) && (this->heartrate > tdata->max_hrt)) {
-                       tdata->max_hrt = (int) this->heartrate;
+               if ((thisw->heartrate > 0) && (thisw->heartrate > tdata->max_hrt)) {
+                       tdata->max_hrt = (int) thisw->heartrate;
                }
 
-               if (this->cadence > 0) {
+               if (thisw->cadence > 0) {
                        pts_cad++;
-                       tot_cad += (float) this->cadence;
+                       tot_cad += (float) thisw->cadence;
                }
 
-               if ((this->cadence > 0) && (this->cadence > tdata->max_cad)) {
-                       tdata->max_cad = (int) this->cadence;
+               if ((thisw->cadence > 0) && (thisw->cadence > tdata->max_cad)) {
+                       tdata->max_cad = (int) thisw->cadence;
                }
 
-               if (this->creation_time && (this->creation_time < tdata->start)) {
-                       tdata->start = this->creation_time;
+               if (thisw->creation_time && (thisw->creation_time < tdata->start)) {
+                       tdata->start = thisw->creation_time;
                }
 
-               if (this->creation_time > tdata->end) {
-                       tdata->end = this->creation_time;
+               if (thisw->creation_time > tdata->end) {
+                       tdata->end = thisw->creation_time;
                        if (tdata->start == 0) {
                                tdata->start = tdata->end;
                        }
                }
-               prev = this;
-               if (!this->shortname || !this->shortname[0] ) {
+               prev = thisw;
+               if (!thisw->shortname || !thisw->shortname[0] ) {
                        snprintf(tkptname, sizeof(tkptname), "%s-%d", 
                                trk->rte_name ? trk->rte_name : "" , tkpt);
-                       this->shortname = xstrdup(tkptname);
+                       thisw->shortname = xstrdup(tkptname);
                }
                tkpt++;
        }
index e3ea63aa967b688333028d5380d3380508f8b651..0ef0e4396d95a46538c29880415cd81ca4d4aa1c 100644 (file)
--- a/session.c
+++ b/session.c
@@ -54,7 +54,7 @@ start_session(const char *name, const char *filename)
        if (session_ct == 0) QUEUE_INIT(&session_list);
        session_ct++;
 
-       s = xcalloc(1, sizeof(*s));
+       s = (session_t*) xcalloc(1, sizeof(*s));
        ENQUEUE_TAIL(&session_list, &s->Q);
        QUEUE_INIT(&s->category_list);
        s->nr = session_ct;
@@ -114,4 +114,3 @@ session_free(session_t *s)
        xfree(s->filename);
        xfree(s);
 }
-
index 118425b6be47bccc129d753687edd2f7786dae3a..cc138e884ecb9d14223cf2ed5e1276cd8d8e291e 100644 (file)
@@ -183,8 +183,8 @@ trackfilter_parse_time_opt(const char *arg)
 static int
 trackfilter_init_qsort_cb(const void *a, const void *b)
 {
-       const trkflt_t *ra = a;
-       const trkflt_t *rb = b;
+       const trkflt_t *ra = (const trkflt_t*) a;
+       const trkflt_t *rb = (const trkflt_t*) b;
 
        return ra->first_time - rb->first_time;
 }
@@ -437,7 +437,7 @@ trackfilter_merge(void)
        
        if (track_pts < 1) return;
        
-       buff = xcalloc(track_pts, sizeof(*buff));
+       buff = (waypoint **)xcalloc(track_pts, sizeof(*buff));
 
        j = 0;
        for (i = 0; i < track_ct; i++)          /* put all points into temp buffer */
index b64e73d152470c44d4213271acadec3154e84eb5..197b0bbdc36489c4e767b3fd58d0895715bb1fd1 100644 (file)
--- a/unicsv.c
+++ b/unicsv.c
@@ -542,8 +542,8 @@ unicsv_fondle_header(char *ibuf)
 
                if (column % 4 == 0) {
                        int sz = (column + 4) * sizeof(*unicsv_fields_tab);
-                       if (column == 0) unicsv_fields_tab = xmalloc(sz);
-                       else unicsv_fields_tab = xrealloc(unicsv_fields_tab, sz);
+                       if (column == 0) unicsv_fields_tab = (field_e*) xmalloc(sz);
+                       else unicsv_fields_tab = (field_e*) xrealloc(unicsv_fields_tab, sz);
                        for (i = 0; i < 4; i++) unicsv_fields_tab[column + i] = fld_terminator;
                }
 
@@ -1192,7 +1192,7 @@ unicsv_print_data_time(const time_t atime)
 static void
 unicsv_waypt_enum_cb(const waypoint *wpt)
 {
-       char *shortname;
+       const char *shortname;
        garmin_fs_t *gmsd;
 
        shortname = (wpt->shortname) ? wpt->shortname : "";
@@ -1267,7 +1267,7 @@ unicsv_waypt_disp_cb(const waypoint *wpt)
 {
        double lat, lon, alt;
        char *cout = NULL;
-       char *shortname;
+       const char *shortname;
        garmin_fs_t *gmsd;
 #ifdef UNICSV_GC_READY
        const geocache_data *gc_data = NULL;
diff --git a/util.c b/util.c
index 7c0c18e6b960e499961c7f519c0568fffffa0bd1..3d7f163340e37820a9e00d360fda7df7afa90d26 100644 (file)
--- a/util.c
+++ b/util.c
@@ -243,7 +243,7 @@ xstrappend(char *src, const char *newd)
        }
 
        newsz = strlen(src) + strlen(newd) + 1;
-       src = xxrealloc(src, newsz, file, line);
+       src = (char *) xxrealloc(src, newsz, file, line);
        strcat(src, newd);
 
        return src;
@@ -338,12 +338,12 @@ xvasprintf(char **strp, const char *fmt, va_list ap)
        bufsize = 0;
        for (;;) {
                if (bufsize == 0) {
-                       if ((buf = xmalloc(FIRSTSIZE)) == NULL) {
+                       if ((buf = (char *) xmalloc(FIRSTSIZE)) == NULL) {
                                *strp = NULL;
                                return -1;
                        }
                        bufsize = FIRSTSIZE;
-               } else if ((newbuf = xrealloc(buf, nextsize)) != NULL) {
+               } else if ((newbuf = (char *) xrealloc(buf, nextsize)) != NULL) {
                        buf = newbuf;
                        bufsize = nextsize;
                } else {
@@ -397,7 +397,7 @@ xvasprintf(char **strp, const char *fmt, va_list ap)
        if (bufsize > outsize + 1) {
                const unsigned ptrsz = sizeof(buf);
                if (((bufsize + ptrsz + 1) / ptrsz) > ((outsize + ptrsz + 1) / ptrsz))
-                       buf = xrealloc(buf, outsize + 1);       
+                       buf = (char *) xrealloc(buf, outsize + 1);
 
        }
        *strp = buf;
@@ -412,7 +412,7 @@ char *
 pstrdup(char *src)
 {
        int len = src[0];
-       char *obuf = xmalloc(len + 1);
+       char *obuf = (char *) xmalloc(len + 1);
 
        memcpy(obuf, src + 1, len);
        obuf[len] = 0;
@@ -629,7 +629,7 @@ strenquote(const char *str, const char quot_char)
        else cin = (char *)str;
        
        len = strlen(cin);
-       cout = tmp = xmalloc((len * 2) + 3);
+       cout = tmp = (char *) xmalloc((len * 2) + 3);
        
        *cout++ = quot_char;
        while (*cin) {
@@ -699,7 +699,7 @@ be_readu16(const void *p)
 void
 be_write16(void *addr, const unsigned value)
 {
-       unsigned char *p = addr;
+       unsigned char *p = (unsigned char *) addr;
        p[0] = value >> 8;
        p[1] = value;
        
@@ -719,28 +719,28 @@ be_write32(void *pp, const unsigned i)
 signed int
 le_read16(const void *addr)
 {
-       const unsigned char *p = addr;
+       const unsigned char *p = (const unsigned char *) addr;
        return p[0] | (p[1] << 8);
 }
 
 unsigned int
 le_readu16(const void *addr)
 {
-       const unsigned char *p = addr;
+       const unsigned char *p = (const unsigned char *) addr;
        return p[0] | (p[1] << 8);
 }
 
 signed int
 le_read32(const void *addr)
 {
-       const unsigned char *p = addr;
+       const unsigned char *p = (const unsigned char *) addr;
        return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
 }
 
 unsigned int
 le_readu32(const void *addr)
 {
-       const unsigned char *p = addr;
+       const unsigned char *p = (const unsigned char *) addr;
        return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
 }
 
@@ -751,8 +751,8 @@ le_readu32(const void *addr)
 void
 le_read64(void *dest, const void *src)
 {
-       char *cdest = dest;
-       const char *csrc = src;
+       char *cdest = (char *) dest;
+       const char *csrc = (const char *) src;
 
        if (i_am_little_endian) {
                memcpy(dest, src, 8);
@@ -767,7 +767,7 @@ le_read64(void *dest, const void *src)
 void
 le_write16(void *addr, const unsigned value)
 {
-       unsigned char *p = addr;
+       unsigned char *p = (unsigned char *) addr;
        p[0] = value;
        p[1] = value >> 8;
        
@@ -776,7 +776,7 @@ le_write16(void *addr, const unsigned value)
 void 
 le_write32(void *addr, const unsigned value)
 {
-       unsigned char *p = addr;
+       unsigned char *p = (unsigned char *) addr;
        p[0] = value;
        p[1] = value >> 8;
        p[2] = value >> 16;
@@ -1033,7 +1033,7 @@ void
 endian_write_double(void* ptr, double d, int write_le)
 {
   int i;
-  char *optr = ptr;
+  char *optr = (char *) ptr;
 // Word order is different on arm, but not on arm-eabi.  
 #if defined(__arm__) && !defined(__ARM_EABI__)
   char r[8];
@@ -1060,7 +1060,7 @@ endian_write_float(void* ptr, float f, int write_le)
 {
   char *r = (char *)(void *)&f;
   int i;
-  char *optr = ptr;
+  char *optr = (char *) ptr;
 
   if ( i_am_little_endian == write_le ) {
          memcpy( ptr, &f, 4);
@@ -1132,7 +1132,7 @@ strsub(const char *s, const char *search, const char *replace)
                return NULL;
        }
        
-       d = xmalloc(len + rlen);
+       d = (char *) xmalloc(len + rlen);
 
        /* Copy first part */
        len = p - s;
@@ -1160,11 +1160,11 @@ gstrsub(const char *s, const char *search, const char *replace)
        int slen = strlen(search);
        int rlen = strlen(replace);
 
-       o = xmalloc(olen + 1);
+       o = (char *) xmalloc(olen + 1);
        
        while ((c = strstr(src, search))) {
                olen += (rlen - slen);
-               o = xrealloc(o, olen + 1);
+               o = (char *) xrealloc(o, olen + 1);
                memcpy(o + ooffs, src, c - src);
                ooffs += (c - src);
                src = c + slen;
@@ -1257,7 +1257,7 @@ convert_human_date_format(const char *human_datef)
        char prev;
        int ylen;
        
-       result = xcalloc((2*strlen(human_datef)) + 1, 1);
+       result = (char *) xcalloc((2*strlen(human_datef)) + 1, 1);
        cout = result;
        prev = '\0';
        ylen = 0;
@@ -1324,7 +1324,7 @@ convert_human_time_format(const char *human_timef)
        char *result, *cin, *cout;
        char prev;
        
-       result = xcalloc((2*strlen(human_timef)) + 1, 1);
+       result = (char *) xcalloc((2*strlen(human_timef)) + 1, 1);
        cout = result;
        prev = '\0';
        
@@ -1645,7 +1645,7 @@ entitize(const char * str, int is_html)
 #endif
 
        /* enough space for the whole string plus entity replacements, if any */
-       tmp = xcalloc((strlen(str) + elen + 1), 1);
+       tmp = (char *) xcalloc((strlen(str) + elen + 1), 1);
        strcpy(tmp, str);
 
        /* no entity replacements */
@@ -1788,7 +1788,7 @@ char *get_filename(const char *fname)
  */
 void gb_setbit(void *buf, const gbuint32 nr)
 {
-       unsigned char *bytes = buf;
+       unsigned char *bytes = (unsigned char *) buf;
        bytes[nr / 8] |= (1 << (nr % 8));
 }
 
@@ -1797,7 +1797,7 @@ void gb_setbit(void *buf, const gbuint32 nr)
  */
 char gb_getbit(const void *buf, const gbuint32 nr)
 {
-       const unsigned char *bytes = buf;
+       const unsigned char *bytes = (const unsigned char *) buf;
        return (bytes[nr / 8] & (1 << (nr % 8)));
        
 }
diff --git a/vecs.c b/vecs.c
index 1d1f51504785a4c6d566b9b0f5014281ceaf9e90..09289c43fd9e0c53c37b3e703d644dbade4d3d37 100644 (file)
--- a/vecs.c
+++ b/vecs.c
@@ -1331,8 +1331,8 @@ static signed int
 alpha (const void *a, const void *b)
 {
 
-       const vecs_t *const *ap = a;
-       const vecs_t *const *bp = b;
+       const vecs_t *const *ap = (const vecs_t *const*) a;
+       const vecs_t *const *bp = (const vecs_t *const*) b;
        
        return case_ignore_strcmp((*ap)->desc , (*bp)->desc);
 }
@@ -1363,7 +1363,7 @@ sort_and_unify_vecs(int *ctp)
 #endif // CSVFMTS_ENABLED
 
 
-       svp = xcalloc(vc, sizeof(style_vecs_t *));
+       svp = (vecs_t **)xcalloc(vc, sizeof(style_vecs_t *));
        /* Normal vecs are easy; populate the first part of the array. */
        for (vec = vec_list; vec->vec; vec++, i++) {
                svp[i] = vec;
@@ -1376,9 +1376,9 @@ sort_and_unify_vecs(int *ctp)
        /* Walk the style list, parse the entries, dummy up a "normal" vec */
        for (svec = style_list; svec->name; svec++, i++)  {
                xcsv_read_internal_style(svec->style_buf);
-               svp[i] = xcalloc(1, sizeof **svp);
+               svp[i] = (vecs_t*) xcalloc(1, sizeof **svp);
                svp[i]->name = svec->name;
-               svp[i]->vec = xmalloc(sizeof(*svp[i]->vec));
+               svp[i]->vec = (ff_vecs_t*) xmalloc(sizeof(*svp[i]->vec));
                svp[i]->extension = xcsv_file.extension;
                *svp[i]->vec = *vec_list[0].vec; /* Interits xcsv opts */
                /* Reset file type to inherit ff_type from xcsv for everything
@@ -1397,11 +1397,11 @@ sort_and_unify_vecs(int *ctp)
                switch(xcsv_file.datatype) {
                        case 0:
                        case wptdata:
-                               svp[i]->vec->cap[ff_cap_rw_wpt] = ff_cap_read | ff_cap_write; break;
+                               svp[i]->vec->cap[ff_cap_rw_wpt] = (ff_cap) (ff_cap_read | ff_cap_write); break;
                        case trkdata:
-                               svp[i]->vec->cap[ff_cap_rw_trk] = ff_cap_read | ff_cap_write; break;
+                               svp[i]->vec->cap[ff_cap_rw_trk] = (ff_cap) (ff_cap_read | ff_cap_write); break;
                        case rtedata:
-                               svp[i]->vec->cap[ff_cap_rw_rte] = ff_cap_read | ff_cap_write; break;
+                               svp[i]->vec->cap[ff_cap_rw_rte] = (ff_cap)(ff_cap_read | ff_cap_write); break;
                        default: ;
                }
                svp[i]->desc = xcsv_file.description;
diff --git a/vmem.c b/vmem.c
index f1834f1c269d3e7be6115f67b6d3a8b4dcc9abde..c35a02fa2bbffca7c11af449dcfcac01318ca0ca 100644 (file)
--- a/vmem.c
+++ b/vmem.c
@@ -33,7 +33,7 @@ vmem_alloc(size_t size, int flags)
        if (flags & VMFL_NOZERO)
                vm.mem = xmalloc(size);
        else
-               vm.mem = xcalloc(size, 1);
+               vm.mem = (char *) xcalloc(size, 1);
        vm.size = size;
        return vm;
 }
@@ -63,5 +63,3 @@ vmem_realloc(vmem_t *vm, size_t size)
        }
        return;
 }
-
-
index 7b0471b34e3fc5c781594585e5c4f50971a2ae9f..2fbeaa618bcee61c959c08d68a462981514814f3 100644 (file)
--- a/xmltag.c
+++ b/xmltag.c
@@ -71,7 +71,7 @@ copy_xml_tag( xml_tag **copy, xml_tag *src, xml_tag *parent ) {
                return;
        }
        
-       res = xcalloc( 1, sizeof(xml_tag));
+       res = (xml_tag*) xcalloc( 1, sizeof(xml_tag));
        *copy = res;
        
        memcpy( res, src, sizeof(xml_tag));
@@ -158,4 +158,3 @@ fs_xml *fs_xml_alloc( long type ) {
        result->fs.convert = fs_xml_convert;
        return result;
 }
-